<?php
/**
 * Created by PhpStorm.
 * User: User
 * Date: 2017/9/20
 * Time: 9:07
 */

$num1=$_GET["num1"];
$num2=$_GET["num2"];
$op=$_GET["op"];

switch($op){
    case '+':$result=$num1+$num2;break;
    case '-':$result=$num1+$num2;break;
    case '*':$result=$num1+$num2;break;
    case '%':$result=$num1+$num2;break;
}
?>

<html>
<body>
<form action="cal.php" method="get">
<input type="text" name="num1" value="<?php echo $num1?>"/>
<select name="op">
    <option value="+" <?php echo $op=='+'?'selected':''?>>+</option>
    <option value="-" <?php echo $op=='-'?'selected':''?>>-</option>
    <option value="*" <?php echo $op=='*'?'selected':''?>>*</option>
    <option value="%" <?php echo $op=='%'?'selected':''?>>%</option>
</select>
<input type="text" name="num2" value="<?php echo $num2?>"/>
=
<input type="text" name="result"/>
<button type="submit">计算</button>
</form>
</body>
</html>


